package com.yitiao.data_algorithms.leetcode.editor.cn;

import com.yitiao.data_algorithms.leetcode.editor.cn.base.ListNode;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.TreeNode;

import java.util.ArrayList;
import java.util.List;

class Subsets {
    // 2022-08-26 12:26:15
    public static void main(String[] args) {
        Solution solution = new Subsets().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public List<List<Integer>> subsets(int[] nums) {
            List<List<Integer>> ans = new ArrayList<>();

            for (int i = 0; i < Math.pow(2, nums.length); i++) {
                List<Integer> tmp = new ArrayList<>();
                for (int j = 0; j < nums.length; j++) {
                    // 将二进制位为 1 的加入 List
                    if ((i & (1 << j)) != 0) {
                        tmp.add(nums[j]);
                    }
                }
                ans.add(tmp);
            }
            return ans;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}